<?php
/**
 * Created by IntelliJ IDEA.
 * User: jimmyhsu
 * Date: 2017/5/14
 * Time: 00:14
 */
include('checkLogin.php');
$course_id = $_GET['course_id'];
echo "<th>文件名</th><th>上传者</th><th>上传时间</th><th>操作</th>";
$sql = "select * from sharedfile join userinfo where author_id=userinfo.id and course_id='$course_id'";
if ($query = mysqli_query($cn, $sql)) {
    while ($row = mysqli_fetch_assoc($query)) {
        $file_name = $row['title'] . '.' . $row['type'];
        $f_id = $row['f_id'];
        $type = $row['type'];
        $uploader = $row['real_name'];
        $upload_time = $row['release_time'];
        $upload_time = substr($upload_time, 0, strrpos($upload_time, ':'));
        echo "<tr><td><a href=\"downloadService.php?filename=file/$course_id/$f_id.$type&outfile_name=$file_name\">$file_name</a></td><td>$uploader</td><td>$upload_time</td>
<td><a class=\"btn btn-danger\" href=\"javascript:void(0);\" onclick=\"removeFile(".$row['f_id'].")\">删除</a></td></tr>";
    }
} else {
    die('db_error');
}